package com.example.lvsuo.service.impl;

import com.example.lvsuo.entity.LogType;
import com.example.lvsuo.entity.vo.xzhvo.Log;
import com.example.lvsuo.service.ILogJobService;
import com.example.lvsuo.entity.LogJob;
import com.example.lvsuo.mapper.LogJobMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 工作日志表 服务实现类
 * </p>
 *
 * @author 心心念念
 * @since 2021-03-30
 */
@Service
public class LogJobServiceImpl extends ServiceImpl<LogJobMapper, LogJob> implements ILogJobService {

    @Override
    public List<Log> lists(Log map) {

        return this.baseMapper.lists(map);
    }

    @Override
    public List<Log> lipos(Log map) {
        return this.baseMapper.lipos(map);
    }

    @Override
    public List<Log> rizhileixing(Log map) {
        return this.baseMapper.rizhileixing(map);
    }

    @Override
    public Integer xiugai(Log map) {
        return this.baseMapper.xiugai(map);
    }

    @Override
    public List<Log> xuanranerji(Log map) {
        return this.baseMapper.xuanranerji(map);
    }

    @Override
    public List<Log>  getAnjianselect(Log map) {
        return this.baseMapper.getAnjianselect(map);
    }

    @Override
    public Integer tianjia(Log map) {
        return this.baseMapper.tianjia(map);
    }

    @Override
    public List<Log> chaxunpop(Log map) {
        return this.baseMapper.chaxunpop(map);

    }

    @Override
    public List<LogType> digui() {
        return thiss(this.baseMapper.digui(),0);
    }
         //递归
    public  List<LogType>  thiss(List<LogType>  list ,int id){

        List<LogType> collect = list.stream().filter(a -> a.getLogTypePid()==id).map(a -> {
            List<LogType> menus = thiss(list,Integer.valueOf(a.getId().toString()));
            a.setChildren(menus);
            return a;
        }).collect(Collectors.toList());
        return  collect;
    }
}
